import java.util.Collection;
import java.util.Set;
import java.util.TreeMap;

/**
 * @author: gao
 * @create-date: 2025/3/11 9:46
 */

public class Solution {
    public static void main(String[] args) {
        TreeMap<Character,Integer> tree1 = new TreeMap<>();
        //底层是二叉搜索树，要想实现插入与删除，进行的是k的比较
        //如果k是其他类，那么这个类必须是可比较的
        tree1.put('a',1);
        tree1.put('b',2);
        tree1.put('c',3);
        tree1.put('d',4);
        tree1.put('e',5);
        tree1.put('a',1);
        tree1.put('b',2);
        tree1.put('c',3);
        tree1.put('x',1);
        tree1.put('y',2);
        tree1.put('z',3);
        System.out.println(tree1.get('a'));//根据key获取value，打印1
        tree1.put('a',10);//设置key对应的value是唯一的

        System.out.println(tree1.get('a'));//打印10
        System.out.println(tree1.get('e'));//返回null

        System.out.println(tree1.getOrDefault('f',6));

        System.out.println(tree1.containsKey('c'));
        System.out.println(tree1.containsKey('f'));

        Set<Character> setTree = tree1.keySet();
        System.out.println(setTree);

        Collection<Integer> collection = tree1.values();
        System.out.println(collection);

        Integer in = tree1.remove('a');
        System.out.println(in);
    }
}